﻿@using DirectSell.Model.Message
@using Webdiyer.WebControls.Mvc;
@model PageMessages
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/User/Views/Shared/UserLayout.cshtml";
}

<!-- APP MAIN ==========-->
<main id="app-main" class="app-main">
    <div class="wrap">
        <section class="app-content">
            <div class="widget p-lg">
                <h4 class="m-b-lg">在线留言</h4>

                <button type="button" onclick="member_show('发起留言','/User/Message/MessageView')" class="btn btn-warning" data-toggle="modal" data-target="#myModal">
                    我要发起留言
                </button>
                <div class="m-b-lg nav-tabs-horizontal">

                    <ul class="nav nav-tabs tabs1" role="tablist">
                        <li role="presentation" class="active"><a href="#tab-1" aria-controls="tab-3" role="tab" data-toggle="tab">我的留言</a></li>
                        <li role="presentation"><a href="#tab-2" aria-controls="tab-1" role="tab" data-toggle="tab">我收到的留言</a></li>
                    </ul><!-- .nav-tabs -->
                    <div class="tab-content">
                        <div role="tabpanel" class="tab-pane in active fade" id="tab-1">
                            <div class="clearfix">
                                <nav class="page-redcolor">
                                    <div id="orders">
                                        <div id="dvCategoryResults">
                                            @Html.Partial("List", Model.Messages_1)
                                        </div>
                                        <div style="width:100%;overflow:auto;">
                                            <div style="float:right">Go to page<select id="pib"></select></div>
                                         @Ajax.Pager(Model.Messages_1, new PagerOptions
                                         {

                                             ContainerTagName = "ul",
                                             CssClass = "pagination",
                                             PageIndexBoxId = "pib",
                                             Id = "mypager",
                                             CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
                                             DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
                                             PagerItemTemplate = "<li>{0}</li>"
                                         }).AjaxOptions(a => a.SetUpdateTargetId("orders").EnablePartialLoading())
                                        </div>
                                    </div>

                                </nav>
                       </div>
                    </div><!-- .tab-pane  -->
                        <div role="tabpanel" class="tab-pane fade" id="tab-2">
                            <div class="clearfix">
                                <nav class="page-redcolor">
                                    <div id="orders1">
                                        <div id="dvCategoryResults1">
                                            @Html.Partial("List_1", Model.Messages_2)
                                        </div>
                                        <div style="width:100%;overflow:auto;">
                                            <div style="float:right">Go to page<select id="pib1"></select></div>
                                         @Ajax.Pager(Model.Messages_2, new PagerOptions
                                     {
                                         PageIndexParameterName = "id",
                                         ContainerTagName = "ul",
                                         CssClass = "pagination",
                                         PageIndexBoxId = "pib1",
                                         Id = "mypager",
                                         CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
                                         DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
                                         PagerItemTemplate = "<li>{0}</li>"
                                     }).AjaxOptions(a => a.SetUpdateTargetId("orders1").EnablePartialLoading())
                                        </div>
                                    </div>

                                </nav>
                            </div>
                        </div><!-- .tab-pane  -->
                    @section scripts{ @{Html.RegisterMvcPagerScriptResource();}}
                </div><!-- .widget -->
                </div>
                </div>
        </section><!-- #dash-content -->
    </div><!-- .wrap -->
    <!-- APP FOOTER -->
    <div class="wrap p-t-0">
        <footer class="app-footer">
            <div class="clearfix">
                <div class="copyright text-center w100">@DirectSell.Common.Url.CommonConfig.companyName &copy;</div>
            </div>
        </footer>
    </div>
    <!-- Modal -->
    @*<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
          
        </div>
    </div>*@

    <!-- /#app-footer -->
</main>
<!--========== END app main -->
<script>
    /*弹出层*/
    /*
        参数解释：
        title	标题
        url		请求的url
        id		需要操作的数据id
        w		弹出层宽度（缺省调默认值）
        h		弹出层高度（缺省调默认值）
    */
    function layer_show(title, url, w, h) {
        if (title == null || title == '') {
            title = false;
        };
        if (url == null || url == '') {
            url = "404.html";
        };
        if (w == null || w == '') {
            w = 800;
        };
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        };
        layer.open({
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false, //不固定
            maxmin: true,
            shade: 0.4,
            title: title,
            content: url
        });
    }
    /*关闭弹出框口*/
    function layer_close() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
    /*发起留言*/
    function member_show(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    //查看留言
    function show_msg(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }
    function DelMsg(id) {
        layer.confirm('确定要删除该信息吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            //加载层
            var index = layer.load(1, {
                shade: [0.1, '#fff']
            });
            $.ajax({
                type: "post",
                url: "/User/Message/DeleteMessage",
                data: { id: id },
            }).success(function (message) {
           $("#dvCategoryResults").load('@(Url.Action("List", "Message", null, Request.Url.Scheme))?pageIndex=' + $("#pib").val());
            layer.msg('删除成功', { icon: 1 });
            }).fail(function (err) {
                layer.msg('系统错误,请稍后重试', { icon: 2 });
            })
            layer.close(index)//关闭加载层
        }, function () {
            layer.close();
        });
    }
    //标为已读
    function Alread(id) {
    //加载层
    var index = layer.load(1, {
        shade: [0.1, '#fff']
    });
    $.ajax({
        type: "post",
        url: "/User/Message/AlRead",
        data: { id: id },
    }).success(function (message) {
        $("#dvCategoryResults1").load('@(Url.Action("List_1", "Message", null, Request.Url.Scheme))?id=' + $("#pib1").val());
        layer.msg('成功', { icon: 1 });
    }).fail(function (err) {
        layer.msg('系统错误,请稍后重试', { icon: 2 });
    })
    layer.close(index)//关闭加载层
    }
</script>